// 必填項驗證
export const required = {
  required: true,
  message: "此項為必填項",
  trigger: ["blur", "change"],
};
// 手機號碼驗證
export function validatePhone(aaa, value, callback) {
  let reg = /^1[34578]\d{9}$/;
  if (value == "" || value == undefined || value == null) {
    return Promise.resolve();
  } else {
    if (!reg.test(value)) {
      return Promise.resolve(new Error("手机号码格式错误"));
    } else {
      // console.log("通过");
      return Promise.resolve();
    }
  }
}
// 密码验证 /^ZB[a-zA-Z0-9]{1,100}$/;
export function validatePassword(aaa, value, callback) {
  let reg = /^(?![A-Z]+$)(?![a-z]+$)(?!\d+$)(?![\W_]+$)\S{6,20}$/;
  if (value == "" || value == undefined || value == null) {
    return Promise.resolve();
  } else {
    if (!reg.test(value)) {
      return Promise.reject(new Error("密码格式错误"));
    } else {
      return Promise.resolve();
    }
  }
}
